# -*- coding: utf-8 -*-
# !/usr/bin/env python
from utils.mysql_utils import query_to_list



def get_deploy_soft_log_info(soft_id):
    sql_parameter = []
    if soft_id:
        sql_fragment = "WHERE a.soft_id = %s"
        sql_parameter.append(soft_id)
    else:
        sql_fragment = ''

    sql = """
    SELECT a.*,b.host_ip,b.host_connection_port,b.host_connection_code,c.resource_user_name,c.resource_user_pass,
    c.resource_user_keyfile
    FROM soft_management a 
    LEFT JOIN hosts_management b ON a.host_id = b.host_id
    LEFT JOIN resource_user c ON b.resource_user_ids = c.resource_user_ids AND c.resource_user_default = 1
    %s
    """ % sql_fragment
    data = query_to_list(sql, sql_parameter, True)

    return data